package com.sxj.product.application.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sxj.product.application.UserService;
import com.sxj.product.domain.UserInfo;
import com.sxj.product.mapper.UserMapper;

import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class UserServiceImpl implements UserService {

	@Autowired
	private UserMapper userMapper;
	
//	@Autowired
//	private RedisTemplate redisTemplate;
	
//	@Autowired(required=false)
//    private ArticleSearchRepository articleSearchRepository;
	
	@Override
	public List<UserInfo> queryUserInfo(UserInfo info) {
		log.info("{}dwoafheinisd",info.getName());
		PageHelper.startPage(1, 1);
		Page<UserInfo> page = userMapper.queryUserInfo(info);
//		ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
//		operations.set(info.getName(), info);
		return page;
	}

//	@Override
//	public void testSearch() {
//		// TODO Auto-generated method stub
//        Author author = new Author();
//        author.setId(1);
//        author.setName("tianshouzhi");
//        author.setRemark("java developer");
//
//        Tutorial tutorial = new Tutorial();
//        tutorial.setId(1);
//        tutorial.setName("elastic search");
//
//        Article article = new Article();
//        article.setId(1L);
//        article.setTitle("springboot integreate elasticsearch");
//        article.setAbstracts("springboot integreate elasticsearch is very easy");
//        article.setTutorial(tutorial);
//        article.setAuthor(author);
//        article.setContent("elasticsearch based on lucene,"
//                + "spring-data-elastichsearch based on elaticsearch"
//                + ",this tutorial tell you how to integrete springboot with spring-data-elasticsearch");
//        article.setPostTime(new Date());
//        article.setClickCount(1L);
//
//        articleSearchRepository.save(article);
//		
//	}
//
//	@Override
//	public void testSaveArticleIndex() {
//		// TODO Auto-generated method stub
//        String queryString = "springboot";//搜索关键字
//        QueryStringQueryBuilder builder = new QueryStringQueryBuilder(queryString);
//        Iterable<Article> searchResult = articleSearchRepository.search(builder);
//        Iterator<Article> iterator = searchResult.iterator();
//        while (iterator.hasNext()) {
//            System.out.println(iterator.next());
//        }
//		
//	}

}
